package action;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import dao.StudentDao;
import dao.impl.StudentDaoImpl;
import entity.Student;

import java.util.List;

/**
 * Created by honghao on 2017/2/24.
 */
public class StudentLoginAction extends ActionSupport implements ModelDriven {
    private static StudentDao dao = new StudentDaoImpl();
    private static Student student;

    public String stuLogin() {
        List<Student> students = dao.findStudentByNameAndStuNumber(student.getName(), student.getStuNumber());
        if (students != null && students.size() > 0) {
            return SUCCESS;
        } else {
            return ERROR;
        }
    }

    @Override
    public Object getModel() {
        return student;
    }
}
